<template>
  <div class="m-header">
    <div class="banner">
      <div class="logo">
        <a href="javascript:;">
          <img src="./../../static/image/LOGO@2x.png" alt="">
        </a>
      </div>
      <ul>
        <li @click="advertising(0)"><router-link :to="{path:'/',query:{type:1}}" :class="{current:type==1|type==undefined}">首页</router-link></li>
        <li @click="advertising(700)"><router-link :to="{path:'/',query:{type:2}}" :class="{current:type==2}">广告投放</router-link></li>
        <li @click="advertising(1400)"><router-link :to="{path:'/',query:{type:3}}" :class="{current:type==3}">流量变现</router-link></li>
        <li><router-link :to="{path:'/',query:{type:4}}" :class="{current:type==4}">接入文档</router-link></li>
        <li><router-link :to="{path:'/aboutLeTui',query:{type:5}}" :class="{current:type==5}">关于乐推</router-link></li>
      </ul>
      <div class="loginBox">
        <!-- <a href="http://localhost:8080/#/login" target="_blank" class="btn login active">登录</a> -->
        <div class="btn login active" @click="login">登录</div>
        <div class="btn register" @click="register">注册</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "m-header",
  data() {
    return {
      type: 1
    };
  },
  created() {
    this.type = this.$route.query.type;
  },
  methods: {
    advertising(TOP) {
      let scroll_to = document.documentElement.scrollTop;
      clearInterval(this.timer);
      if (Math.abs(scroll_to - TOP) < 10) return;
      if (scroll_to < TOP) {
        this.timer = setInterval(() => {
          if (scroll_to >= TOP) {
            clearInterval(this.timer);
          } else {
            scroll_to += 10;
            window.scrollTo(0, scroll_to);
          }
        }, 5);
      } else {
        this.timer = setInterval(() => {
          if (scroll_to < TOP) {
            clearInterval(this.timer);
          } else {
            scroll_to -= 10;
            window.scrollTo(0, scroll_to);
          }
        }, 5);
      }
    },
    login() {
      window.open("http://www.lertui.com/ad/login.html");
    },
    register() {
      window.open("http://www.lertui.com/ad/register.html");
    }
  },
  watch: {
    $route(to, from) {
      this.type = this.$route.query.type;
    }
  }
};
</script>
<style lang="scss">
.m-header {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  height: 100px;
  padding: 24px 0;
  background: #fcfcfc;
  z-index: 9999;
  .current {
    color: #fe5411;
  }
  .logo {
    // display: inline-block;
    width: 200px;
    height: 100%;
    margin: 0 212px 0 0;
    float: left;
  }
  ul {
    // display: inline-block;
    float: left;
    height: 50px;
    line-height: 50px;
    li {
      list-style: none;
      margin-right: 70px;
      display: inline-block;
      a {
        color: #333;
        font-size: 14px;
        display: block;
      }
    }
  }
  .loginBox {
    width: 120px;
    height: 30px;
    border-radius: 15px;
    margin: 10px 10px 0 0;
    border: 1px solid #e3e3e3;
    float: right;
    overflow: hidden;
    text-align: center;
    line-height: 30px;
    font-size: 14px;
    cursor: pointer;
    .btn {
      text-align: center;
      width: 50%;
      float: left;
    }
    .active {
      background: #fe5411;
      color: #fff;
    }
  }
}
</style>

